package cn.tedu.lbs.marketing.web;

import com.tarena.lbs.base.protocol.exception.BusinessException;
import com.tarena.lbs.base.protocol.model.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice(basePackages = "cn.tedu.lbs.marketing.web.controller")
@Slf4j
public class GlobalExceptionHandler {
    //捕获2种异常
    @ExceptionHandler(BusinessException.class)
    public Result handleBizException(BusinessException e){
        log.error("系统业务异常捕获",e);
        return Result.fail(e);
    }

    @ExceptionHandler({Throwable.class})
    public Result handleSystemError(Throwable e){
        log.error("系统异常捕获",e);
        return Result.fail();
    }
}
